    if (user_mode(regs)) {
        regs_user->abi = perf_reg_abi(current);
        regs_user->regs = regs;
    } else if (!(current->flags & PF_KTHREAD)) {
        perf_get_regs_user(regs_user, regs);
    } else {



void perf_get_regs_user(struct perf_regs *regs_user,
struct pt_regs *regs)
{
regs_user->regs = task_pt_regs(current);
regs_user->abi = perf_reg_abi(current);
}



/* Userspace stacktrace - based on kernel/trace/trace_sysprof.c */
static void
arch_stack_walk_user_maple(const struct pt_regs *regs)
{
    u64 fp = 0;
    u64 pc = 0;
    u64 sp = 0;
    if (regs != NULL && user_mode(regs)) {
        fp = (regs->regs[29]);
        pc = (regs->pc);
        sp = (regs->sp);
        //printk("Maple test0: pc:%llx fp:%llx sp:%llx\n", pc, fp, sp);
    } else if (!(current->flags & PF_KTHREAD)) {
        struct pt_regs * user_reg = task_pt_regs(current);
        fp = (user_reg->regs[29]);
        pc = (user_reg->pc);
        sp = (user_reg->sp);
        //printk("Maple test1: pc:%llx fp:%llx sp:%llx\n", pc, fp, sp);
    } else {
        printk("Maple no registers?: \n");
        return;
    }

    u64 prevPc = 0;
    int index = 0;
    int err = 0;

    //printk("Maple #0: pc:pc:%llx fp:pc:%llx \n", pc, fp);
    while (1) {
        index++;
        pagefault_disable();
        err = copy_from_user(&fp, fp, sizeof(fp));
        err = copy_from_user(&pc, fp + 8, sizeof(fp));
        pagefault_enable();
        //printk("Maple next: pc:%llx fp:%llx err:%d\n", pc, fp, err);
        if (!pc || !fp) {
            //printk("Maple invalid pc or lr.\n");
            break;
        }

        if (prevPc == pc) {
            //printk("Maple repeat pc.\n");
            break;
        }
        //printk("Maple #%d: %llx\n", index, (void *)pc);
        prevPc = pc;
    }
}
